﻿using System.Windows.Controls;
using SimpleTool.Base;
using System.Windows.Input;
using System.Collections.Specialized;
using Prism.Events;
using System.Globalization;
using System.Windows.Data;
using SimpleTool.Server;
using System.Windows;
using Microsoft.Extensions.DependencyInjection;
using Serilog;

namespace SimpleTool.SerialTool.SerialControl
{

    /// <summary>
    /// UserControl1.xaml 的交互逻辑
    /// </summary>
    public partial class SerialConfigUI : UserControl
    {
        public readonly ILogger Logger = Log.ForContext<SerialConfigUI>();

        public SerialConfigUI()
        {
            InitializeComponent();

            this.Loaded += LoadFinish;
        }

        private void LoadFinish(object sender, RoutedEventArgs e)
        {
            App MyApp = (App)Application.Current;
            SerialViewModel ViewModel = MyApp.ServiceProvider.GetRequiredService<SerialViewModel>();
            if (ViewModel == null)
            {
                Logger.Error("config viewmodel service is null");
            }
            else
            {
                this.DataContext = ViewModel;
            }
            this.Unloaded -= LoadFinish;
        }
    }
}
